#!/usr/bin/python3
# -*- coding:utf-8 -*-
# __author__ = '__wuhha__'
from django.urls import path
from channels.routing import ProtocolTypeRouter, URLRouter

from channels.sessions import SessionMiddleware, CookieMiddleware

from youpu.consumer import NotificationsConsumer, MessagesConsumer

#【已弃用】
application = ProtocolTypeRouter({
    # 普通的HTTP请求不需要我们手动在这里添加，框架会自动加载
    'websocket':
        CookieMiddleware(SessionMiddleware(URLRouter([
            path('ws/notifications/', NotificationsConsumer),
            path('ws/<str:username>/', MessagesConsumer),
        ])))

    # 源码【AuthMiddlewareStack】：
    # 显然，我只需要CookieMiddleware和SessionMiddleware
    # # Handy shortcut for applying all three layers at once
    # AuthMiddlewareStack = lambda inner: CookieMiddleware(
    #     SessionMiddleware(AuthMiddleware(inner))
    # )

})
